<?php
require_once '../sub/init.php';
if(@!in_array('huxuan',$navarr))exit('此模块功能已关闭');
require_once ZEAI.'sub/conn.php';
require_once ZEAI.'cache/udata.php';
$t = (ifint($t,'1-4','1'))?$t:1;
$id=intval($id);$jumpurl = HOST.'/m/huxuan_detail.php?id='.$id;
$currfields = "sex,grade";
require_once ZEAI.'m/my_chk_u.php';
$cook_sex=$row['sex'];$cook_grade=$row['grade'];
$row = $db->ROW(__TBL_HUXUAN__,"bmtj_data,hxtime,flag,jzbmtime","id=".$id." AND flag>0","name");
if ($row){
	$flag=$row['flag'];$hxtime=$row['hxtime'];$jzbmtime=$row['jzbmtime'];
	$bmtj_data = $row['bmtj_data'];$bmtj_data_ARR = explode(',',$bmtj_data);
}else{
	if($js==1){
		json_exit(array('flag'=>0,'msg'=>'亲，该活动跑路了~'));
	}else{
		alert('亲，该活动跑路了~',$jumpurl);
	}
}
/****SQL主体*****/
$nodatatips="<div class='nodatatips'><i class='ico'>&#xe8ab;</i>暂时木有记录</div>";
function rows_ulist($rows,$p) {
	global $_ZEAI,$t,$id;
	$uid     = $rows['uid'];
	$nickname = '嘉宾编号：'.$uid;
	$sex      = $rows['sex'];
	$grade    = $rows['grade'];
	$photo_s  = $rows['photo_s'];
	$photo_f  = $rows['photo_f'];
	$areatitle= $rows['areatitle'];
	$birthday = $rows['birthday'];
	$heigh    = $rows['heigh'];
	$edu      = $rows['edu'];
	$gzflag   = $rows['gzflag'];
	$uflag    = $rows['flag'];
	$job     = $rows['job'];
	$photo_ifshow = $rows['photo_ifshow'];
	$aARR = explode(' ',$areatitle);
	$areatitle = (empty($aARR[2]))?$aARR[1]:$aARR[2];
	$unifo1='';
	$unifo1 .= (getage($birthday)<=0)?'':'<b>'.getage($birthday).'岁</b>';
	$unifo1 .= (empty($areatitle))?'':'<b class="ico">&#xe624; '.$areatitle.'</b>';
	$unifo='';
	$unifo .= (empty($heigh))?'':'<b>・</b>'.udata('heigh',$heigh);
	$unifo .= (empty($edu))?'':'<b>・</b>'.udata('edu',$edu);
	$unifo .= (empty($job))?'':'<b>・</b>'.udata('job',$job);
	$unifo=ltrim($unifo,'<b>・</b>');
	$photo_s_url=photo_s_out('{"smb":"m","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$uflag.'","outkind":"url"}');	
	$sex_str = ($sex == 2)?'她':'他';
	$href = 'hongniang_u.php?id='.$id.'&ifhx=1&uid='.$uid;
	$O  = '<dl>';
	$O .= '<dt><a href="'.$href.'"><img src="'.$photo_s_url.'"></a></dt>';
	$O .= '<dd><h4>'.uicon($sex.$grade).'<span>'.$nickname.'</span></h4><h5>'.$unifo1.'</h5><h6>'.$unifo.'</h6></dd>';
	$O .= '<a href="'.$href.'" class="enter">看'.$sex_str.'资料</a>';
	$O .= '</dl>';
	return $O;
}
$_ZEAI['pagesize'] = 8;
if(in_array('sex',$bmtj_data_ARR)){
	if($cook_sex==2){
		$ZEAI_SQL=" a.fid=".$id." AND U.sex=1";
	}else{
		$ZEAI_SQL=" a.fid=".$id." AND U.sex=2";
	}
}else{
	$ZEAI_SQL=" a.fid=".$id;	
}
switch ($t) {
	case 1:
		$ZEAI_SQL   .= " AND a.uid=U.id";
		$ZEAI_SELECT="SELECT a.uid,U.sex,U.grade,U.photo_s,U.photo_f,U.areatitle,U.job,U.birthday,U.heigh,U.edu,U.flag,U.photo_ifshow FROM ".__TBL_HUXUAN_BMU__." a,".__TBL_USER__." U WHERE ".$ZEAI_SQL." ORDER BY a.id DESC";
		$Ctbname=__TBL_HUXUAN_BMU__;
	break;
	case 2:
		$ZEAI_SQL   .= " AND a.senduid=U.id AND a.uid=".$cook_uid;
		$ZEAI_SELECT="SELECT a.senduid AS uid,U.sex,U.grade,U.photo_s,U.photo_f,U.areatitle,U.job,U.birthday,U.heigh,U.edu,U.flag,U.photo_ifshow FROM ".__TBL_HUXUAN_HXU__." a,".__TBL_USER__." U WHERE ".$ZEAI_SQL." ORDER BY a.id DESC";
		$Ctbname=__TBL_HUXUAN_HXU__;
	break;
	case 3:
		$ZEAI_SQL   .= " AND a.uid=U.id AND a.senduid=".$cook_uid;
		$ZEAI_SELECT="SELECT a.uid,U.sex,U.grade,U.photo_s,U.photo_f,U.areatitle,U.job,U.birthday,U.heigh,U.edu,U.flag,U.photo_ifshow FROM ".__TBL_HUXUAN_HXU__." a,".__TBL_USER__." U WHERE ".$ZEAI_SQL." ORDER BY a.id DESC";
		$Ctbname=__TBL_HUXUAN_HXU__;
	break;
	case 4:
		$ZEAI_SQL  .= " AND a.uid=c.senduid AND a.senduid=c.uid AND a.senduid=U.id AND a.uid=".$cook_uid;// GROUP BY a.senduid
		$ZEAI_SELECT="SELECT a.senduid AS uid,U.sex,U.grade,U.photo_s,U.photo_f,U.areatitle,U.job,U.birthday,U.heigh,U.edu,U.flag,U.photo_ifshow FROM ".__TBL_HUXUAN_HXU__." a,".__TBL_USER__." U,".__TBL_HUXUAN_HXU__." c WHERE ".$ZEAI_SQL." ORDER BY a.id DESC";
		$Ctbname=__TBL_HUXUAN_HXU__;
	break;
}
if($submitok=='ZEAI_list'){exit(Zeai_ajax_list_fn($ZEAI_totalP,$p));}
if($t==4){
	$rtt=$db->query("SELECT COUNT(*) FROM ".$Ctbname." a,".__TBL_USER__." U,".$Ctbname." c WHERE ".$ZEAI_SQL);
}else{
	$rtt=$db->query("SELECT COUNT(*) FROM ".$Ctbname." a,".__TBL_USER__." U WHERE ".$ZEAI_SQL);
}
$roww = $db->fetch_array($rtt,'num');
$ZEAI_total = $roww[0];
$ZEAI_totalP= ceil($ZEAI_total/$_ZEAI['pagesize']);
/****SQL主体结束*****/
switch ($t) {
	case 1:$bg = '#fbe7e7';break;
	case 2:$bg = '#fde9f6';break;
	case 3:$bg = '#f7f0e2';break;
	case 4:$bg = '#dcfbea';break;
}?>
<!doctype html><html><head><meta charset="utf-8">
<title>互选大厅 - <?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA;?>
<meta name="generator" content="Zeai.cn HUXUAN1.0" />
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/huxuan_detail.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/huxuan_detail.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
.top_mini4{background-image:url("<?php echo RES;?>m/img/my_bg.png");background-size:100%}
#backtop a{background-color:#fff;color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.hx_ulist dl dd h5 b:first-child{background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.5)}
.ulist_top a{background-color:<?php echo $bg;?>}
.hx_ulist dl .enter{border-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4);color:<?php echo $_ZEAI['mob_mbcolor'];?>}
body{background-color:#fff}
#backtop{bottom:9rem}

#djsbox{display:block;font-size:1.4rem}
#djsbox span{margin:0 .5rem}
#djsbox font{width:2rem;background-color:rgba(0,0,0,0.4);color:#fff;padding:0 .4rem;border-radius:.2rem}
#djsbox i{margin-right:.4rem}

<?php if ($flag == 2){?>
#mini_title {line-height:100%;margin-top:.8rem}
#mini_title .partyflag2{display:block;font-size:1.4rem;margin-top:.2rem}
<?php }?>
.my_browse{padding:0 1.5rem 10rem 1.5rem;margin-top:11rem}
.my_browse dl{border-bottom:#f2f2f2 1px solid;position:relative;height:7rem;box-sizing:border-box}
.my_browse dl dt,.my_browse dl dd{position:absolute;top:1.3rem}
.my_browse dl dt{width:6rem;left:0}
.my_browse dl dt img{width:4.4rem;height:4.4rem;border-radius:2.5rem;object-fit:cover;-webkit-object-fit:cover}
.my_browse dl dd{left:7rem;width:-webkit-calc(100% - 8rem);text-align:left}
.my_browse dl dd b{font-weight:normal;margin:0 .5rem;color:#ccc;font-size:12px}
.my_browse dl dd h6{width:100%;color:#999;margin-top:.3rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.my_browse dl span{color:#999;font-size:1.2rem;position:absolute;right:0;top:1.5rem}
#my_browse_del{display:inline-block;width:6rem;line-height:3rem;position:absolute;top:1rem;right:0px;border-radius:.2rem;font-size:1.6rem;color:#fff/*;background-color:rgba(0,0,0,0.2)*/}
.viptips{width:90%;margin:12rem auto;background-color:#f8f8f8;padding:3rem 2rem;border-radius:.6rem;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}
.viptips font{width:100%;font-size:1.4rem;display:block;margin:0 auto;color:#999}
.viptips font b{color:#f00;margin:0 .2rem;font-weight:normal}
.viptips h5{margin:1rem auto 2rem auto}
.viptips .ivubox span{display:inline-block;width:4rem;height:4rem;border:.2rem solid #fff;border-radius:5rem;margin-left:-.8rem;overflow:hidden;transform:rotate(0deg);}
.viptips .ivubox span img{width:4rem;height:4rem;object-fit:cover;-webkit-object-fit:cover;overflow:hidden}
.viptips .ivubox span img.blur{filter:blur(3px);-webkit-filter:blur(.3rem);display:block}
</style>
</head><body>
<?php 
$mini_title='点击资料进行选择';
switch ($flag){ 
	case 1:
		if(ADDTIME < $jzbmtime){//报名中
			$djs_difftime=$jzbmtime-ADDTIME;
			$mini_title = "<div id='djsbox' diftime=".$djs_difftime."><i class='ico'>&#xe634; 报名倒计时</i><font>00</font><span>时</span><font>00</font><span>分</span><font>00</font><span>秒</span></div>";
		}else{
			$mini_title = "【报名中】";
		}
	break;
	case 2:
		if(ADDTIME<$hxtime){//等待互选
			$djs_difftime=$hxtime-ADDTIME;
			$mini_title = "<div id='djsbox' diftime=".$djs_difftime."><i class='ico'>&#xe634; 距互选还剩</i><font>00</font><span>时</span><font>00</font><span>分</span><font>00</font><span>秒</span></div>";
		}else{
			$mini_title = "<b>【开始互选中】</b><span class='partyflag2'>请点击会员资料后进行选择</span>";
		}
	break;
	case 3:echo $mini_title="活动已结束";break;
}



$mini_class='top_mini4 zeaibg bgcolor yunbox';
$mini_L = '<em onClick="zeai.openurl(\''.$jumpurl.'\')"><i class="ico" >&#xeaca;</i></em>';
require_once ZEAI.'m/top_mini.php';
if(($flag==1 && $jzbmtime>ADDTIME ) || $flag==2 && $hxtime>ADDTIME){?>
    <script>
        var B = o('djsbox').getElementsByTagName('font');
        var Hid = B[0],Mid=B[1],Sid=B[2];
        var diftime = o('djsbox').getAttribute("diftime");
        hx_djs(Hid,Mid,Sid,diftime);
    </script>
<?php }?>
<div class="ulist_top" >
	<a href="huxuan_detail_ulist.php?id=<?php echo $id;?>&t=1" class="<?php echo ($t == 1)?'ed':'';?>"><i class="ico">&#xe8ab;</i><span>互选大厅</span></a>
	<a href="huxuan_detail_ulist.php?id=<?php echo $id;?>&t=2" class="<?php echo ($t == 2)?'ed':'';?>"><i class="ico">&#xe64e;</i><span>谁选了我</span></a>
	<a href="huxuan_detail_ulist.php?id=<?php echo $id;?>&t=3" class="<?php echo ($t == 3)?'ed':'';?>"><i class="ico">&#xe8d5;</i><span>我选了谁</span></a>
	<a href="huxuan_detail_ulist.php?id=<?php echo $id;?>&t=4" class="<?php echo ($t == 4)?'ed':'';?>"><i class="ico">&#xe635;</i><span>互选成功</span></a>
</div>
<div class="hx_ulist" id="ZEAI_list">
<?php if($ZEAI_totalP>0){
	if($t==2 && $cook_grade<=1){?>
		<div class="viptips">
		<?php 
		$SQL2  = " a.senduid=U.id AND a.uid=".$cook_uid;
		$rtt   = $db->query("SELECT COUNT(*) FROM ".__TBL_HUXUAN_HXU__." a,".__TBL_USER__." U WHERE".$SQL2);
		$roww  = $db->fetch_array($rtt);
		$vwnum = $roww[0];
		$rt=$db->query("SELECT a.senduid AS uid,U.sex,U.grade,U.photo_s,U.photo_f,U.areatitle,U.job,U.birthday,U.heigh,U.edu,U.flag,U.photo_ifshow FROM ".__TBL_HUXUAN_HXU__." a,".__TBL_USER__." U WHERE ".$SQL2." ORDER BY a.id DESC LIMIT 6");
		$total = $db->num_rows($rt);
		if ($total > 0){
			echo '<div class="ivubox">';
			$viewblurClass = ($viewlist[$cook_grade]!=1)?' class="blur"':'';
			for($ii=1;$ii<=$total;$ii++) {
				$rows = $db->fetch_array($rt,'name');
				if(!$rows) break;
				$senduid = $rows['senduid'];
				$sex     = $rows['sex'];
				$new     = $rows['new'];
				$new_str = ($new == 1)?'<b></b>':'';
				$photo_s  = $rows['photo_s'];
				$photo_f  = $rows['photo_f'];
				$flag     = $rows['flag'];
                $photo_ifshow = $rows['photo_ifshow'];
				$photo_s_url = (!empty($photo_s) && $photo_f==1)?UP.$photo_s:RES.'photo_s'.$sex.'.png';
				if($photo_ifshow==0 || $flag==-2){$photo_s_url=RES.'photo_m'.$sex.'_hide.png';}
				if($flag==-2)$nickname='***';
				echo '<span><img src="'.$photo_s_url.'"'.$viewblurClass.'></span>';
			}
			echo '</div>';
		}?>
        <font>已经有<b><?php echo $vwnum;?></b>人选择了你</font>
        <h5>缘分就在一瞬间，不错过喜欢你的人</h5>
        <a href="my_vip.php?jumpurl=<?php echo $jumpurl;?>" class="btn size3 zeaibg B yuan" id="vipbtn">　<i class="ico">&#xe6ab;</i> 立即开通VIP查看　</a>
    	</div>
		<?php
	}else{
		echo Zeai_ajax_list_fn($ZEAI_totalP,$p);
	}
}else{echo $nodatatips;}?></div>
<?php if ($ZEAI_total > $_ZEAI['pagesize']){?>
<script>
var ZEAI_totalP = parseInt(<?php echo $ZEAI_totalP; ?>),p=2;
zeaiOnscroll_json={url:'huxuan_detail_ulist'+zeai.extname,data:{submitok:'ZEAI_list',ZEAI_totalP:ZEAI_totalP,id:<?php echo $id;?>,t:<?php echo $t;?>}};
document.body.onscroll = zeaiOnscroll;
</script>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<div class="blankbottom">没有更多了</div>
<?php }?>
<?php if (is_weixin() && ifint($cook_uid)){wx_endurl('您刚刚浏览的页面【互选相亲】',$jumpurl);}?>
<?php require_once ZEAI.'m/TRnav.php';?>
</body></html>
<?php
function hx_ifbm($id,$cook_uid) {
	global $db;
	if(!ifint($id) || !ifint($cook_uid) )return false;
	if($db->ROW(__TBL_HUXUAN_BMU__,"id","fid=".$id." AND uid=".$cook_uid))return true;
	return false;
}
function partyflag($flag) {
	switch ($flag){ 
		case 0:$flag_str = "<span class='partyflag0'>未审核</span>";break;
		case 1:$flag_str = "<span class='partyflag1'>报名中</span>";break;
		case 2:$flag_str = "<span class='partyflag2'>互选中</span>";break;
		case 3:$flag_str = "<span class='partyflag3'>已结束</span>";break;
	}
	return $flag_str;
}
?>